/*
Name: Kabir Kang
File: unittest4.c
Date: 7/13/14
Summary: tests endTurn() function
 */
#include <math.h>
#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include "rngs.h"

int main(int argc, char * argv[])
{
  int i,j;
  struct gameState g;
  int k[10] = {curse, council_room, feast, gardens, mine, remodel, smithy, village, baron, great_hall};

  for(i=2;i<=MAX_PLAYERS;i++)
    {
      initializeGame(i,k,1,&g);
      for (j=0;j<i;j++)
	{
	  printf("Testing player %d \n", j);
	  if(whoseTurn(&g)==j)
	    {
	      printf("endTurn(): PASS turn has advanced. \n");
	    }
	  else
	    {
	      printf("endTurn(): FAIL checking if turn advanced. \n");
	    }
	  if(g.handCount[j]==5)
	    {
	      printf("endTurn(): PASS player %d has 5 cards. \n", j);
	    }
	  else
	    {
	      printf("endTurn(): FAIL player %d doesn't have 5 cards. \n", j);
	    }
	  if(j<i-1)
	    {
	      if(g.handCount[j+1] == 0)
		{
		  printf("endTurn(): PASS other players have 0 cards. \n");
		}
	      else
		{
		  printf("endTurn(): FAIL other players have cards. \n");
		}
	    }
	  else
	    {
	      if(g.handCount[0] == 0)
		{
		  printf("endTurn(): PASS other players have no cards. \n");
		}
	      else
		{
		  printf("endTurn(): FAIL other players have cards. \n");
		}
	    }
	  endTurn(&g);
	}
	  if (whoseTurn(&g) == 0)
	  {
		  printf("endTurn(): PASS when gameState turn checked to be 0. \n");
	  }
	  else
	  {
		  printf("endTurn(): FAIL when gameState turn not equal to 0. \n");
	  }
    }
  return 0;
}
